﻿using System;
using System.Text;
using System.Collections.Generic;

namespace Model
{
    public class Part
    {
        public const int MIN_NUMBER = 1;
        public const int MAX_NUMBER = 30;

        private List<Verse> verses = null;
        public List<Verse> Verses
        {
            get { return verses; }
        }

        private int number;
        public int Number
        {
            get { return number; }
        }

        public Part(int number, List<Verse> verses)
        {
            this.number = number;
            this.verses = verses;
            if (this.verses != null)
            {
                foreach (Verse verse in this.verses)
                {
                    verse.Part = this;
                }
            }
        }

        private string text;
        public string Text
        {
            get
            {
                if (String.IsNullOrEmpty(text))
                {
                    StringBuilder str = new StringBuilder();
                    if (this.verses != null)
                    {
                        foreach (Verse verse in this.verses)
                        {
                            str.AppendLine(verse.Text);
                        }
                        str.Remove(str.Length - 2, 2);
                    }
                    this.text = str.ToString();
                }
                return this.text;
            }
        }
    }
}
